<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>前端面试题 | 李玉明</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="Web前端面试题目汇总
以下是收集一些面试中经常会遇到的经典面试题以及自己面试过程中有一些未解决的问题，通过对知识的整理以及经验的总结，重新巩固自身的前端基础知识，如有错误或更好的答案，欢迎指正，水平有限，望各位不吝指教。阅读目录:

HTML/CSS部分


JavaScript部分


HTTP


算法相关


Web安全


前端性能


前端架构


正则表达式


职业规划


HTM">
<meta property="og:type" content="article">
<meta property="og:title" content="前端面试题">
<meta property="og:url" content="http://yoursite.com/2016/05/28/Web前端面试题目汇总/index.html">
<meta property="og:site_name" content="李玉明">
<meta property="og:description" content="Web前端面试题目汇总
以下是收集一些面试中经常会遇到的经典面试题以及自己面试过程中有一些未解决的问题，通过对知识的整理以及经验的总结，重新巩固自身的前端基础知识，如有错误或更好的答案，欢迎指正，水平有限，望各位不吝指教。阅读目录:

HTML/CSS部分


JavaScript部分


HTTP


算法相关


Web安全


前端性能


前端架构


正则表达式


职业规划


HTM">
<meta property="og:updated_time" content="2016-05-28T01:13:40.898Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="前端面试题">
<meta name="twitter:description" content="Web前端面试题目汇总
以下是收集一些面试中经常会遇到的经典面试题以及自己面试过程中有一些未解决的问题，通过对知识的整理以及经验的总结，重新巩固自身的前端基础知识，如有错误或更好的答案，欢迎指正，水平有限，望各位不吝指教。阅读目录:

HTML/CSS部分


JavaScript部分


HTTP


算法相关


Web安全


前端性能


前端架构


正则表达式


职业规划


HTM">
  
    <link rel="alternative" href="/atom.xml" title="李玉明" type="application/atom+xml">
  
  
    <link rel="icon" href="/img/favicon.png">
  
  
  <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  
  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  
  
      <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  
  <!-- 加载特效 -->
    <script src="/js/pace.js"></script>
    <link href="/css/pace/pace-theme-flash.css" rel="stylesheet" />
  <script>
      var yiliaConfig = {
          fancybox: true,
          animate: true,
          isHome: false,
          isPost: true,
          isArchive: false,
          isTag: false,
          isCategory: false,
          open_in_new: false
      }
  </script>
</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            
            <img lazy-src="/img/head.jpg" class="js-avatar">
            
        </a>

        <hgroup>
          <h1 class="header-author"><a href="/">liyuming</a></h1>
        </hgroup>

        
        
        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">博客首页</a></li>
                        
                            <li><a href="/archives">作品展示</a></li>
                        
                            <li><a href="/">随笔</a></li>
                        
                            <li><a href="/archives">静心阅读</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fl mail" target="_blank" href="http://my.csdn.net/github_35151727" title="mail">mail</a>
                            
                                <a class="fl github" target="_blank" href="https://github.com/ljym-246810" title="github">github</a>
                            
                                <a class="fl zhihu" target="_blank" href="https://www.zhihu.com/people/li-yu-ming122" title="zhihu">zhihu</a>
                            
                                <a class="fl weibo" target="_blank" href="http://weibo.com/3888047260" title="weibo">weibo</a>
                            
                                <a class="fl google" target="_blank" href="http://weibo.com/u/5089556680?is_all=1" title="google">google</a>
                            
                                <a class="fl twitter" target="_blank" href="https://wx.qq.com/" title="twitter">twitter</a>
                            
                                <a class="fl facebook" target="_blank" href="http://t.qq.com/liujia1046408090?setTheme=1" title="facebook">facebook</a>
                            
                                <a class="fl rss" target="_blank" href="http://www.renren.com/860433942#nogo" title="rss">rss</a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://MOxFIVE.github.io/">MOxFIVE</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.vsay.cn/">DoubleV</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.ccwebsite.com/">兮兮</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.dandyweng.com/">翁天信</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.plqblog.com/views/index.php">潘利强</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.hankin.cn/">hankin</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.waydrow.com/">waydrow</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://silenceport.com">喻南航</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://hubojing.coding.me/">胡博靖</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.lzkzhiliang.com/">zhiliang</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://weilai5432.github.io/">未来部落</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.qiujinfeng.com/">qiujinfeng</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">编程是一种单调的生活，因此程序员比普通人需要更多的关怀，更多的友情。</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">liyuming</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                
                    <img lazy-src="/img/head.jpg" class="js-avatar">
                
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">liyuming</a></h1>
            </hgroup>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">博客首页</a></li>
                
                    <li><a href="/archives">作品展示</a></li>
                
                    <li><a href="/">随笔</a></li>
                
                    <li><a href="/archives">静心阅读</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                <div class="social">
                    
                        <a class="mail" target="_blank" href="http://my.csdn.net/github_35151727" title="mail">mail</a>
                    
                        <a class="github" target="_blank" href="https://github.com/ljym-246810" title="github">github</a>
                    
                        <a class="zhihu" target="_blank" href="https://www.zhihu.com/people/li-yu-ming122" title="zhihu">zhihu</a>
                    
                        <a class="weibo" target="_blank" href="http://weibo.com/3888047260" title="weibo">weibo</a>
                    
                        <a class="google" target="_blank" href="http://weibo.com/u/5089556680?is_all=1" title="google">google</a>
                    
                        <a class="twitter" target="_blank" href="https://wx.qq.com/" title="twitter">twitter</a>
                    
                        <a class="facebook" target="_blank" href="http://t.qq.com/liujia1046408090?setTheme=1" title="facebook">facebook</a>
                    
                        <a class="rss" target="_blank" href="http://www.renren.com/860433942#nogo" title="rss">rss</a>
                    
                </div>
            </nav>
        </header>                
    </div>
</nav>
      <div class="body-wrap"><article id="post-Web前端面试题目汇总" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2016/05/28/Web前端面试题目汇总/" class="article-date">
      <time datetime="2016-05-28T01:06:30.000Z" itemprop="datePublished">2016-05-28</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      前端面试题
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        

        
        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1 id="Web前端面试题目汇总"><a href="#Web前端面试题目汇总" class="headerlink" title="Web前端面试题目汇总"></a>Web前端面试题目汇总</h1><hr>
<p>以下是收集一些面试中经常会遇到的经典面试题以及自己面试过程中有一些未解决的问题，通过对知识的整理以及经验的总结，重新巩固自身的前端基础知识，如有错误或更好的答案，欢迎指正，水平有限，望各位不吝指教。<br>阅读目录:</p>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label0" target="_blank" rel="external">HTML/CSS部分</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label1" target="_blank" rel="external">JavaScript部分</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label2" target="_blank" rel="external">HTTP</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label3" target="_blank" rel="external">算法相关</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label4" target="_blank" rel="external">Web安全</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label5" target="_blank" rel="external">前端性能</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label6" target="_blank" rel="external">前端架构</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label7" target="_blank" rel="external">正则表达式</a></li>
</ul>
<ul>
<li><a href="http://www.cnblogs.com/bigboyLin/p/5272902.html#_label8" target="_blank" rel="external">职业规划</a></li>
</ul>
<hr>
<h2 id="HTML-CSS部分"><a href="#HTML-CSS部分" class="headerlink" title="HTML/CSS部分"></a><strong>HTML/CSS部分</strong></h2><blockquote>
<p>1、什么是盒子模型？</p>
</blockquote>
<p>在网页中，一个元素占有空间的大小由几个部分构成，其中包括元素的内容（content），元素的内边距（padding），元素的边框（border），元素的外边距（margin）四个部分。这四个部分占有的空间中，有的部分可以显示相应的内容，而有的部分只用来分隔相邻的区域或区域。4个部分一起构成了css中元素的盒模型。</p>
<blockquote>
<p>2、行内元素有哪些？块级元素有哪些？ 空(void)元素有那些？</p>
</blockquote>
<p>行内元素：a、b、span、img、input、strong、select、label、em、button、textarea<br>块级元素：div、ul、li、dl、dt、dd、p、h1-h6、blockquote<br>空元素：即没有内容的HTML元素，例如：br、meta、hr、link、input、img</p>
<blockquote>
<p>3、CSS实现垂直水平居中</p>
</blockquote>
<p>一道经典的问题，实现方法有很多种，以下是其中一种实现：<br>HTML结构：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;div class=&quot;wrapper&quot;&gt;</span><br><span class="line">    &lt;div class=&quot;content&quot;&gt;&lt;/div&gt;</span><br><span class="line">&lt;/div&gt;</span><br></pre></td></tr></table></figure></p>
<p>CSS：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">    .wrapper&#123;position:relative;&#125;</span><br><span class="line">    .content&#123;</span><br><span class="line">    background-color:#6699FF;</span><br><span class="line">    width:200px;</span><br><span class="line">    height:200px;</span><br><span class="line">    position: absolute;        //父元素需要相对定位</span><br><span class="line">    top: 50%;</span><br><span class="line">    left: 50%;</span><br><span class="line">    margin-top:-100px ;   //二分之一的height，width</span><br><span class="line">    margin-left: -100px;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<blockquote>
<p>4、简述一下src与href的区别</p>
</blockquote>
<p>href 是指向网络资源所在位置，建立和当前元素（锚点）或当前文档（链接）之间的链接，用于超链接。<br>src是指向外部资源的位置，指向的内容将会嵌入到文档中当前标签所在位置；在请求src资源时会将其指向的资源下载并应用到文档内，例如js脚本，img图片和frame等元素。当浏览器解析到该元素时，会暂停其他资源的下载和处理，直到将该资源加载、编译、执行完毕，图片和框架等元素也如此，类似于将所指向资源嵌入当前标签内。这也是为什么将js脚本放在底部而不是头部。</p>
<blockquote>
<p>5、什么是CSS Hack?</p>
</blockquote>
<p>一般来说是针对不同的浏览器写不同的CSS,就是 CSS Hack。<br>IE浏览器Hack一般又分为三种，条件Hack、属性级Hack、选择符Hack（详细参考CSS文档：css文档）。例如：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"> // 1、条件Hack</span><br><span class="line">&lt;!--[if IE]&gt;</span><br><span class="line">   &lt;style&gt;</span><br><span class="line">         .test&#123;color:red;&#125;</span><br><span class="line">   &lt;/style&gt;</span><br><span class="line">&lt;![endif]--&gt;</span><br><span class="line">// 2、属性Hack</span><br><span class="line"> .test&#123;</span><br><span class="line"> color:#090\9; /* For IE8+ */</span><br><span class="line"> *color:#f00;  /* For IE7 and earlier */</span><br><span class="line"> _color:#ff0;  /* For IE6 and earlier */</span><br><span class="line"> &#125;</span><br><span class="line">// 3、选择符Hack</span><br><span class="line"> * html .test&#123;color:#090;&#125;       /* For IE6 and earlier */</span><br><span class="line"> * + html .test&#123;color:#ff0;&#125;     /* For IE7 */</span><br></pre></td></tr></table></figure></p>
<blockquote>
<p>6、简述同步和异步的区别</p>
</blockquote>
<p>同步是阻塞模式，异步是非阻塞模式。<br>同步就是指一个进程在执行某个请求的时候，若该请求需要一段时间才能返回信息，那么这个进程将会一直等待下去，直到收到返回信息才继续执行下去；<br>异步是指进程不需要一直等下去，而是继续执行下面的操作，不管其他进程的状态。当有消息返回时系统会通知进程进行处理，这样可以提高执行的效率</p>
<blockquote>
<p>7、px和em的区别</p>
</blockquote>
<p>px和em都是长度单位，区别是，px的值是固定的，指定是多少就是多少，计算比较容易。em得值不是固定的，并且em会继承父级元素的字体大小。<br>浏览器的默认字体高都是16px。所以未经调整的浏览器都符合: 1em=16px。那么12px=0.75em, 10px=0.625em</p>
<blockquote>
<p>8、什么叫优雅降级和渐进增强？</p>
</blockquote>
<p>渐进增强 progressive enhancement：<br>针对低版本浏览器进行构建页面，保证最基本的功能，然后再针对高级浏览器进行效果、交互等改进和追加功能达到更好的用户体验。<br>优雅降级 graceful degradation：<br>一开始就构建完整的功能，然后再针对低版本浏览器进行兼容。<br>区别：<br>a. 优雅降级是从复杂的现状开始，并试图减少用户体验的供给<br>b. 渐进增强则是从一个非常基础的，能够起作用的版本开始，并不断扩充，以适应未来环境的需要<br>c. 降级（功能衰减）意味着往回看；而渐进增强则意味着朝前看，同时保证其根基处于安全地带</p>
<blockquote>
<p>9、浏览器的内核分别是什么?</p>
</blockquote>
<p>IE: trident内核<br>Firefox：gecko内核<br>Safari：webkit内核<br>Opera：以前是presto内核，Opera现已改用Google Chrome的Blink内核<br>Chrome：Blink(基于webkit，Google与Opera Software共同开发)</p>
<hr>
<h2 id="JavaScript部分"><a href="#JavaScript部分" class="headerlink" title="JavaScript部分"></a><strong>JavaScript部分</strong></h2><blockquote>
<p>怎样添加、移除、移动、复制、创建和查找节点？</p>
</blockquote>
<p>1）创建新节点<br>createDocumentFragment() //创建一个DOM片段<br>createElement() //创建一个具体的元素<br>createTextNode() //创建一个文本节点<br>2）添加、移除、替换、插入<br>appendChild() //添加<br>removeChild() //移除<br>replaceChild() //替换<br>insertBefore() //插入<br>3）查找<br>getElementsByTagName() //通过标签名称<br>getElementsByName() //通过元素的Name属性的值<br>getElementById() //通过元素Id，唯一性</p>
<blockquote>
<p>实现一个函数clone，可以对JavaScript中的5种主要的数据类型（包括Number、String、Object、Array、Boolean）进行值复制。</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line">   /**</span><br><span class="line"> * 对象克隆</span><br><span class="line"> * 支持基本数据类型及对象</span><br><span class="line"> * 递归方法</span><br><span class="line"> */</span><br><span class="line">function clone(obj) &#123;</span><br><span class="line">    var o;</span><br><span class="line">    switch (typeof obj) &#123;</span><br><span class="line">        case &quot;undefined&quot;:</span><br><span class="line">            break;</span><br><span class="line">        case &quot;string&quot;:</span><br><span class="line">            o = obj + &quot;&quot;;</span><br><span class="line">            break;</span><br><span class="line">        case &quot;number&quot;:</span><br><span class="line">            o = obj - 0;</span><br><span class="line">            break;</span><br><span class="line">        case &quot;boolean&quot;:</span><br><span class="line">            o = obj;</span><br><span class="line">            break;</span><br><span class="line">        case &quot;object&quot;: // object 分为两种情况 对象（Object）或数组（Array）</span><br><span class="line">            if (obj === null) &#123;</span><br><span class="line">                o = null;</span><br><span class="line">            &#125; else &#123;</span><br><span class="line">                if (Object.prototype.toString.call(obj).slice(8, -1) === &quot;Array&quot;) &#123;</span><br><span class="line">                    o = [];</span><br><span class="line">                    for (var i = 0; i &lt; obj.length; i++) &#123;</span><br><span class="line">                        o.push(clone(obj[i]));</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125; else &#123;</span><br><span class="line">                    o = &#123;&#125;;</span><br><span class="line">                    for (var k in obj) &#123;</span><br><span class="line">                        o[k] = clone(obj[k]);</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            break;</span><br><span class="line">        default:</span><br><span class="line">            o = obj;</span><br><span class="line">            break;</span><br><span class="line">    &#125;</span><br><span class="line">    return o;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>如何消除一个数组里面重复的元素？</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">// 方法一：</span><br><span class="line">var arr1 =[1,2,2,2,3,3,3,4,5,6],</span><br><span class="line">    arr2 = [];</span><br><span class="line">for(var i = 0,len = arr1.length; i&lt; len; i++)&#123;</span><br><span class="line">    if(arr2.indexOf(arr1[i]) &lt; 0)&#123;</span><br><span class="line">        arr2.push(arr1[i]);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">document.write(arr2); // 1,2,3,4,5,6</span><br></pre></td></tr></table></figure>
<blockquote>
<p>在Javascript中什么是伪数组？如何将伪数组转化为标准数组？</p>
</blockquote>
<p>  伪数组（类数组）：无法直接调用数组方法或期望length属性有什么特殊的行为，但仍可以对真正数组遍历方法来遍历它们。典型的是函数的argument参数，还有像调用getElementsByTagName,document.childNodes之类的,它们都返回NodeList对象都属于伪数组。可以使用Array.prototype.slice.call(fakeArray)将数组转化为真正的Array对象</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">function log()&#123;</span><br><span class="line">      var args = Array.prototype.slice.call(arguments);  </span><br><span class="line">//为了使用unshift数组方法，将argument转化为真正的数组</span><br><span class="line">      args.unshift(&apos;(app)&apos;);</span><br><span class="line"> </span><br><span class="line">      console.log.apply(console, args);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>段落引用Javascript中callee和caller的作用？</p>
</blockquote>
<p>caller是返回一个对函数的引用，该函数调用了当前函数；<br>callee是返回正在被执行的function函数，也就是所指定的function对象的正文</p>
<blockquote>
<p>请描述一下cookies，sessionStorage和localStorage的区别</p>
</blockquote>
<p>sessionStorage用于本地存储一个会话（session）中的数据，这些数据只有在同一个会话中的页面才能访问并且当会话结束后数据也随之销毁。因此sessionStorage不是一种持久化的本地存储，仅仅是会话级别的存储。而localStorage用于持久化的本地存储，除非主动删除数据，否则数据是永远不会过期的。<br>web storage和cookie的区别<br>Web Storage的概念和cookie相似，区别是它是为了更大容量存储设计的。Cookie的大小是受限的，并且每次你请求一个新的页面的时候Cookie都会被发送过去，这样无形中浪费了带宽，另外cookie还需要指定作用域，不可以跨域调用。<br>除此之外，Web Storage拥有setItem,getItem,removeItem,clear等方法，不像cookie需要前端开发者自己封装setCookie，getCookie。但是Cookie也是不可以或缺的：Cookie的作用是与服务器进行交互，作为HTTP规范的一部分而存在 ，而Web Storage仅仅是为了在本地“存储”数据而生。</p>
<blockquote>
<p>统计字符串中字母个数或统计最多字母数。</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">var str = &quot;aaaabbbccccddfgh&quot;;</span><br><span class="line">var obj  = &#123;&#125;;</span><br><span class="line">for(var i=0;i&lt;str.length;i++)&#123;</span><br><span class="line">    var v = str.charAt(i);</span><br><span class="line">    if(obj[v] &amp;&amp; obj[v].value == v)&#123;</span><br><span class="line">        obj[v].count = ++ obj[v].count;</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        obj[v] = &#123;&#125;;</span><br><span class="line">        obj[v].count = 1;</span><br><span class="line">        obj[v].value = v;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">for(key in obj)&#123;</span><br><span class="line">    document.write(obj[key].value +&apos;=&apos;+obj[key].count+&apos;&amp;nbsp;&apos;); // a=4  b=3  c=4  d=2  f=1  g=1  h=1 </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="HTTP"><a href="#HTTP" class="headerlink" title="HTTP"></a><strong>HTTP</strong></h2><blockquote>
<p>一次完整的HTTP事务是怎样的一个过程？</p>
</blockquote>
<p>基本流程：<br>a. 域名解析<br>b. 发起TCP的3次握手<br>c. 建立TCP连接后发起http请求<br>d. 服务器端响应http请求，浏览器得到html代码<br>e. 浏览器解析html代码，并请求html代码中的资源<br>f. 浏览器对页面进行渲染呈现给用户</p>
<blockquote>
<p>HTTP的状态码有哪些?<br>HTTPS是如何实现加密？</p>
</blockquote>
<hr>
<h2 id="算法相关"><a href="#算法相关" class="headerlink" title="算法相关"></a><strong>算法相关</strong></h2><blockquote>
<p>手写数组快速排序</p>
</blockquote>
<p>关于快排算法的详细说明，可以参考阮一峰老师的文章快速排序<br>“快速排序”的思想很简单，整个排序过程只需要三步：<br>（1）在数据集之中，选择一个元素作为”基准”（pivot）。<br>（2）所有小于”基准”的元素，都移到”基准”的左边；所有大于”基准”的元素，都移到”基准”的右边。<br>（3）对”基准”左边和右边的两个子集，不断重复第一步和第二步，直到所有子集只剩下一个元素为止。<br>参考代码：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"> var quickSort = function(arr) &#123;</span><br><span class="line">　　if (arr.length &lt;= 1) &#123; return arr; &#125;</span><br><span class="line">　　var pivotIndex = Math.floor(arr.length / 2);</span><br><span class="line">　　var pivot = arr.splice(pivotIndex, 1)[0];</span><br><span class="line">　　var left = [];</span><br><span class="line">　　var right = [];</span><br><span class="line">　　for (var i = 0; i &lt; arr.length; i++)&#123;</span><br><span class="line">　　　　if (arr[i] &lt; pivot) &#123;</span><br><span class="line">　　　　　　left.push(arr[i]);</span><br><span class="line">　　　　&#125; else &#123;</span><br><span class="line">　　　　　　right.push(arr[i]);</span><br><span class="line">　　　　&#125;</span><br><span class="line">　　&#125;</span><br><span class="line">　　return quickSort(left).concat([pivot], quickSort(right));</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>JavaScript实现二分法查找</p>
</blockquote>
<p>二分法查找，也称折半查找，是一种在有序数组中查找特定元素的搜索算法。查找过程可以分为以下步骤：<br>（1）首先，从有序数组的中间的元素开始搜索，如果该元素正好是目标元素（即要查找的元素），则搜索过程结束，否则进行下一步。<br>（2）如果目标元素大于或者小于中间元素，则在数组大于或小于中间元素的那一半区域查找，然后重复第一步的操作。<br>（3）如果某一步数组为空，则表示找不到目标元素。<br>参考代码:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">// 非递归算法</span><br><span class="line">       function binary_search(arr, key) &#123;</span><br><span class="line">           var low = 0,</span><br><span class="line">               high = arr.length - 1;</span><br><span class="line">           while(low &lt;= high)&#123;</span><br><span class="line">               var mid = parseInt((high + low) / 2);</span><br><span class="line">               if(key == arr[mid])&#123;</span><br><span class="line">                   return  mid;</span><br><span class="line">               &#125;else if(key &gt; arr[mid])&#123;</span><br><span class="line">                   low = mid + 1;</span><br><span class="line">               &#125;else if(key &lt; arr[mid])&#123;</span><br><span class="line">                   high = mid -1;</span><br><span class="line">               &#125;else&#123;</span><br><span class="line">                   return -1;</span><br><span class="line">               &#125;</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;;</span><br><span class="line">       var arr = [1,2,3,4,5,6,7,8,9,10,11,23,44,86];</span><br><span class="line">       var result = binary_search(arr,10);</span><br><span class="line">       alert(result); // 9 返回目标元素的索引值</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">// 递归算法</span><br><span class="line">      function binary_search(arr,low, high, key) &#123;</span><br><span class="line">          if (low &gt; high)&#123;</span><br><span class="line">              return -1;</span><br><span class="line">          &#125;</span><br><span class="line">          var mid = parseInt((high + low) / 2);</span><br><span class="line">          if(arr[mid] == key)&#123;</span><br><span class="line">              return mid;</span><br><span class="line">          &#125;else if (arr[mid] &gt; key)&#123;</span><br><span class="line">              high = mid - 1;</span><br><span class="line">              return binary_search(arr, low, high, key);</span><br><span class="line">          &#125;else if (arr[mid] &lt; key)&#123;</span><br><span class="line">              low = mid + 1;</span><br><span class="line">              return binary_search(arr, low, high, key);</span><br><span class="line">          &#125;</span><br><span class="line">      &#125;;</span><br><span class="line">      var arr = [1,2,3,4,5,6,7,8,9,10,11,23,44,86];</span><br><span class="line">      var result = binary_search(arr, 0, 13, 10);</span><br><span class="line">      alert(result); // 9 返回目标元素的索引值</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="Web安全"><a href="#Web安全" class="headerlink" title="Web安全"></a><strong>Web安全</strong></h2><blockquote>
<p>你所了解到的Web攻击技术</p>
</blockquote>
<p>（1）XSS（Cross-Site Scripting，跨站脚本攻击）：指通过存在安全漏洞的Web网站注册用户的浏览器内运行非法的HTML标签或者JavaScript进行的一种攻击。<br>（2）SQL注入攻击<br>（3）CSRF（Cross-Site Request Forgeries，跨站点请求伪造）：指攻击者通过设置好的陷阱，强制对已完成的认证用户进行非预期的个人信息或设定信息等某些状态更新。</p>
<hr>
<h2 id="前端性能"><a href="#前端性能" class="headerlink" title="前端性能"></a><strong>前端性能</strong></h2><blockquote>
<p>如何优化图像、图像格式的区别</p>
<p>浏览器是如何渲染页面的？</p>
</blockquote>
<hr>
<h2 id="前端架构"><a href="#前端架构" class="headerlink" title="前端架构"></a><strong>前端架构</strong></h2><blockquote>
<p>对MVC、MVVM的理解</p>
</blockquote>
<hr>
<h2 id="正则表达式"><a href="#正则表达式" class="headerlink" title="正则表达式"></a><strong>正则表达式</strong></h2><blockquote>
<p>写一个function，清除字符串前后的空格。（兼容所有浏览器）</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">function trim(str) &#123;</span><br><span class="line">    if (str &amp;&amp; typeof str === &quot;string&quot;) &#123;</span><br><span class="line">        return str.replace(/(^\s*)|(\s*)$/g,&quot;&quot;); //去除前后空白符</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>使用正则表达式验证邮箱格式</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">var reg = /^(\w)+(\.\w+)*@(\w)+((\.\w&#123;2,3&#125;)&#123;1,3&#125;)$/;</span><br><span class="line">var email = &quot;example@qq.com&quot;;</span><br><span class="line">console.log(reg.test(email));  // true</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="职业规划"><a href="#职业规划" class="headerlink" title="职业规划"></a><strong>职业规划</strong></h2><blockquote>
<p>对前端工程师这个职位你是怎么样理解的？</p>
</blockquote>
<p>a. 前端是最贴近用户的程序员，前端的能力就是能让产品从 90分进化到 100 分，甚至更好<br>b. 参与项目，快速高质量完成实现效果图，精确到1px；<br>c. 与团队成员，UI设计，产品经理的沟通；<br>d. 做好的页面结构，页面重构和用户体验；<br>e. 处理hack，兼容、写出优美的代码格式；<br>f. 针对服务器的优化、拥抱最新前端技术。</p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2016/05/28/Web前端面试题目汇总/">前端面试题</a></p>
        <p><span>文章作者:</span><a href="/" title="访问 liyuming 的个人博客">liyuming</a></p>
        <p><span>发布时间:</span>2016年05月28日 - 09时06分</p>
        <p><span>最后更新:</span>2016年05月28日 - 09时13分</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2016/05/28/Web前端面试题目汇总/" title="前端面试题">http://yoursite.com/2016/05/28/Web前端面试题目汇总/</a>
            <span class="copy-path" data-clipboard-text="原文: http://yoursite.com/2016/05/28/Web前端面试题目汇总/　　作者: liyuming" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script src="/js/clipboard.min.js"></script>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" title="中国大陆 (CC BY-NC-SA 3.0 CN)" target = "_blank">"署名-非商用-相同方式共享 3.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



<nav id="article-nav">
  
  
    <a href="/2016/05/27/chengxuyuan1md/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">程序员爱情观</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>

    <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录</strong>
    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Web前端面试题目汇总"><span class="toc-number">1.</span> <span class="toc-text">Web前端面试题目汇总</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML-CSS部分"><span class="toc-number">1.1.</span> <span class="toc-text">HTML/CSS部分</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JavaScript部分"><span class="toc-number">1.2.</span> <span class="toc-text">JavaScript部分</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTTP"><span class="toc-number">1.3.</span> <span class="toc-text">HTTP</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#算法相关"><span class="toc-number">1.4.</span> <span class="toc-text">算法相关</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Web安全"><span class="toc-number">1.5.</span> <span class="toc-text">Web安全</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#前端性能"><span class="toc-number">1.6.</span> <span class="toc-text">前端性能</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#前端架构"><span class="toc-number">1.7.</span> <span class="toc-text">前端架构</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#正则表达式"><span class="toc-number">1.8.</span> <span class="toc-text">正则表达式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#职业规划"><span class="toc-number">1.9.</span> <span class="toc-text">职业规划</span></a></li></ol></li></ol>
</div>
<input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

<script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script>
    var valueHide = "隐藏目录";
    var valueShow = "显示目录";

    if ($(".left-col").is(":hidden")) {
        $("#tocButton").attr("value", valueShow);
    }
    $("#tocButton").click(function() {
        if ($("#toc").is(":hidden")) {
            $("#tocButton").attr("value", valueHide);
            $("#toc").slideDown(320);
        }
        else {
            $("#tocButton").attr("value", valueShow);
            $("#toc").slideUp(350);
        }
    })
    if ($(".toc").length < 1) {
        $("#toc, #tocButton").hide();
    }
</script>





<div class="bdsharebuttonbox">
	<a href="#" class="fx fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
	<a href="#" class="fx fa-weixin bds_weixin" data-cmd="weixin" title="分享到微信"></a>
	<a href="#" class="fx fa-qq bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
	<a href="#" class="fx fa-facebook-official bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
	<a href="#" class="fx fa-twitter bds_twi" data-cmd="twi" title="分享到Twitter"></a>
	<a href="#" class="fx fa-linkedin bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a>
	<a href="#" class="fx fa-files-o bds_copy" data-cmd="copy" title="分享到复制网址"></a>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>




    
      <div class="duoshuo" id="comments">
    <!-- 多说评论框 start -->
    <div class="ds-thread" data-thread-key="2016/05/28/Web前端面试题目汇总/" data-title="前端面试题" data-url="http://yoursite.com/2016/05/28/Web前端面试题目汇总/"></div>
    <!-- 多说评论框 end -->
    <!-- 多说公共JS代码 start (一个网页只需插入一次) -->
    <script type="text/javascript">
    var duoshuoQuery = {short_name:"null"};
    (function() {
        var ds = document.createElement('script');
        ds.type = 'text/javascript';ds.async = true;
        ds.src = '/js/embed.js';
        ds.charset = 'UTF-8';
        (document.getElementsByTagName('head')[0] 
         || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
    </script>
    <!-- 多说公共JS代码 end -->
</div>

    



    <div class="scroll" id="post-nav-button">
        
            <a href="/" title="回到主页"><i class="fa fa-home"></i></a>
        
        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>
        
            <a href="/2016/05/27/chengxuyuan1md/" title="下一篇: 程序员爱情观">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>
    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2016/05/28/Web前端面试题目汇总/">前端面试题</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/27/chengxuyuan1md/">程序员爱情观</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/27/一道常被人轻视的前端JS面试题/">JS篇</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/26/chengxuyuan/">如何成为一个优秀的码农</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/26/无标题Markdown/">程序员之路</a></li></ul>
    <script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
    <script>
        $(".post-list").addClass("toc-article");
        $(".post-list-item a").attr("target","_blank");
        $("#post-nav-button > a:nth-child(2)").click(function() {
            $(".fa-bars, .fa-times").toggle();
            $(".post-list").toggle(300);
            if ($(".toc").length > 0) {
                $("#toc, #tocButton").toggle(200, function() {
                    if ($(".switch-area").is(":visible")) {
                        $("#tocButton").attr("value", valueHide);
                        }
                    })
            }
            else {
            }
        })
    </script>



    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                &copy; 2016 liyuming
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/luuman/hexo-theme-spfk" target="_blank">spfk</a> by luuman
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" >海贼到访数: 
                            <span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>, </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit">本页阅读量: 
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>

    </div>
    <script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>

    <script>
        $(document).ready(function() {
            var backgroundnum = 24;
            var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
            $("#mobile-nav").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
            $(".left-col").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
        })
    </script>





<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    $(document).ready(function() {
        if ($("#comments").length < 1) {
            $("#scroll > a:nth-child(2)").hide();
        };
    })
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

  <script language="javascript">
    $(function() {
        $("a[title]").each(function() {
            var a = $(this);
            var title = a.attr('title');
            if (title == undefined || title == "") return;
            a.data('title', title).removeAttr('title').hover(

            function() {
                var offset = a.offset();
                $("<div id=\"anchortitlecontainer\"></div>").appendTo($("body")).html(title).css({
                    top: offset.top - a.outerHeight() - 15,
                    left: offset.left + a.outerWidth()/2 + 1
                }).fadeIn(function() {
                    var pop = $(this);
                    setTimeout(function() {
                        pop.remove();
                    }, pop.text().length * 800);
                });
            }, function() {
                $("#anchortitlecontainer").remove();
            });
        });
    });
</script>


  </div>
</body>
</html>